<!-- 优秀教师 -->
<template>
	<view class="container">
		<view class="c-rich">
			<mp-html :content="goodInfo.detail.content" />
			<view class="c-video" v-if="goodInfo.detail.videosarr_arr.length>0">
				<view class="video" v-for="item in goodInfo.detail.videosarr_arr" :key="item.name" @click="onVideo(item)">
					<image :src="baseURL + item.img" mode="widthFix"></image>
					<view class="video-position">
						<u-icon name="play-right" size="34" bold color="#fff"></u-icon>
						<text>查看视频</text>
					</view>
				</view>
			</view>
		</view>
		
		<view class="c-block">
			<view class="c-headline" v-if="goodList.lenght!=0">
				<text>往期优秀教师</text>
			</view>
			<scroll-view scroll-y="true" class="block-scroll">
				<view class="block-list padding-xs">
					<view class="block-item radius shadow padding" v-for="item in goodList" :key="item.id" @click="toGoodTeach(item.id)">
						<image :src="baseURL + item.img" mode=""></image>
						<view class="block-item-info">
							<text class="block-item-info_title">{{item.name}}</text>
							<text class="block-item-info_date">{{item.title}}</text>
						</view>
					</view>
				</view>
			</scroll-view>
		</view>
		
	</view>
</template>

<script>
	export default {
		name: "goodTeach",
		data() {
			return {
				// 详情
				goodInfo: {},
				// 往届列表
				goodList: []
			}
		},
		onLoad(query) {
			this.getGoodDetail(query.id)
			this.getGoodHistory()
		},
		methods: {
			// 打开视频号
			onVideo(info){
				wx.openChannelsActivity({
					feedId:info.id,
					finderUserName:info.name
				})
			},
			// 获取往届列表
			getGoodHistory() {
				this.$http.getGoodHistory({
					type: 1
				}).then(res => {
					this.goodList = res.data
				})
			},
			// 获取详情
			getGoodDetail(id) {
				this.$http.getGoodDetail({
					id
				}).then(res => {
					this.goodInfo = res
				})
			},
			// 优秀教师介绍页
			toGoodTeach(id) {
				uni.redirectTo({
					url: "/pages/pages_index/inside/goodTeach?id=" + id
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.container {
		background-color: #fff;
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);
		.c-rich {
			&>image {
				width: 100%;
			}
			.rich-video{
				width: 100%;
			}
		}

		.c-video{
			margin-top: 20rpx;
			.video{
				width: 100%;
				position: relative;
				margin-top: 20rpx;
				&>image{
					width: 100%;
				}
				.video-position{
					position: absolute;
					top: 0;
					left: 0;
					width: 100%;
					height: 100%;
					z-index: 99;
					background-color: rgba(0, 0, 0, 0.4);
					color: #fff;
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;
					&>text{
						margin-top: 20rpx;
					}
				}
			}
		}

		.c-block {
			width: 100%;
			padding: 0 20rpx;
			box-sizing: border-box;
			.c-headline {
				font-size: 34rpx;
				font-weight: bold;
			}
			.block-scroll {
				width: 100%;
				height: 360rpx;
				.block-list {
					width: 100%;
					height: 100%;

					.block-item {
						flex-shrink: 0;
						width: 100%;
						height: 120rpx;
						background-color: #fff;
						display: flex;
						align-items: center;
						box-shadow: 0 0 10rpx 0 rgba(0, 0, 0, 0.2);
						margin-bottom: 20rpx;
						&>image {
							width: 90rpx;
							height: 90rpx;
							border-radius: 50%;
							margin-right: 15rpx;
						}

						.block-item-info {
							width: calc(100% - 105rpx);
							display: flex;
							flex-direction: column;

							&>text {
								overflow: hidden;
								text-overflow: ellipsis;
								white-space: nowrap;
							}

							.block-item-info_date {
								font-size: 28rpx;
								color: #888;
							}

							.block-item-info_title {
								font-size: 32rpx;
								font-weight: bold;
							}
						}
					}
				}
			}
		}
	}
</style>
